﻿@{
    ViewBag.Title = "处理任务";
    var id = Model != null ? Model.ID : 0;
}
@using ZBJF.Warranty.Common.Enums.InsuranceWarranty
@using ZBJF.Warranty.WebProvider
@using EnumHelper = ZBJF.Warranty.Common.Common.EnumHelper
@using ZBJF.Warranty.BLL;
@model ZBJF.Warranty.Model.InsuranceWarrantyRecord

<style type="text/css">
    #tbInsuranceWarrantyRecordItem input[type=text] {
        width: 90%;
    }

    #tbInsuranceWarrantyRecordFree input[type=text] {
        width: 90%;
    }
</style>
@Scripts.Render("~/bundles/StarRaty")
@Styles.Render("~/Content/StarRaty")
<ul id="myTab" class="nav nav-tabs">
    <li class="active"><a href="#editInfo" data-toggle="tab">任务处理</a></li>
    <li>
        <a href="#OpreateLogs" data-toggle="tab">
            操作日志
        </a>
    </li>
    <li>
        <a href="#processLog" data-toggle="tab">
            流程日志
        </a>
    </li>
</ul>
<ul></ul>
<div id="myTabContent" class="tab-content">
    <div class="tab-pane  fade in active" id="editInfo">
        @using (Html.BeginForm("SaveInsuranceWarrantyRecordItem", "InsuranceWarrantyRecord", FormMethod.Post, new { id = "mvcForm", name = "mvcForm", enctype = "multipart/form-data" }))
        {
            @Html.AntiForgeryToken()
            @Html.HiddenFor(m => m.ID)
            @Html.HiddenFor(m => m.InsuranceOrderId)
            <h4>常用功能</h4>
            <div class="border-gray">
                <a class="btn margin-10" href="javascript:void(0)" onclick="showInsuranceOrderInfoLayer()">保单信息</a>
                @if (ViewBag.ParentStatusCode == (byte)InsuranceWarrantyStatus.Processing)
                {
                    <a class="btn margin-10" href="javascript:void(0)" onclick="showWarrantyRecordEditLayer()">补充案件信息</a>
                }
                <a class="btn margin-10" href="javascript:void(0)" onclick="showIWRDataCollectLayer()">资料收集</a>
                <a class="btn margin-10" href="javascript:void(0)" onclick="showIWRPickUpInfoLayer()">取件信息</a>
                <a class="btn margin-10" href="javascript:void(0)" onclick="showSendBackInfoLayer()">寄件信息</a>
                <a class="btn btn-info margin-10" href="javascript:void(0)">工单状态：@ServiceFactory.InsuranceWarrantyRecordStatusServiceInstance.GetStatusName(Model.Status)</a>
            </div>

            <h4>报案信息</h4>
            <table class="table table-responsive table-bordered table-hover">
                <tr>
                    <th class="w200">报案人：</th>
                    <td>@Model.Reporter</td>
                    <th class="w200">报案人手机：</th>
                    <td>@Model.ReporterPhone</td>
                </tr>
                <tr>
                    <th>报案日期：</th>
                    <td>@Model.CreateTime</td>
                    <th>出险日期：</th>
                    <td>@Model.ExpectAccidentDate</td>
                </tr>
            </table>
            <h4>出险信息</h4>
            <table class="table table-responsive table-bordered table-hover">
                <tr>
                    <th class="w200">被保险人（出险人）：</th>
                    <td>@Model.InsuranceOrder.UserName</td>
                    <th class="w200">被保险人电话：</th>
                    <td>@Model.InsuranceOrder.UserPhone</td>
                    <th class="w200">证件号码：</th>
                    <td>@Model.InsuranceOrder.CertificateNO</td>
                </tr>
                <tr>
                    <th class="w200">出险地点：</th>
                    <td>@(Model.D_Province != null ? Model.D_Province.ProvinceName : string.Empty) @(Model.D_City != null ? Model.D_City.CityName : string.Empty)</td>
                    <th>出险地点（详细地址）：</th>
                    <td colspan="3">
                        @Model.AccidentAddress
                    </td>
                </tr>
                <tr>
                    <th>出险经过说明：</th>
                    <td colspan="5">
                        @Model.AccidentProsess
                    </td>
                </tr>
                <tr>
                    <th>备注信息：</th>
                    <td colspan="5">@Model.Remark</td>
                </tr>
            </table>
            <h4>被保险设备信息</h4>
            <table class="table table-responsive table-bordered table-hover">
                <tr>
                    <th class="w200">品牌：</th>
                    <td>@Model.InsuranceOrder.ProductBrandName</td>
                    <th class="w200">型号：</th>
                    <td>@Model.InsuranceOrder.ProductModelName</td>
                    <th class="w200">设备识别码：</th>
                    <td>@(string.IsNullOrEmpty(Model.InsuranceOrder.IMEI) ? Model.InsuranceOrder.IDFV : Model.InsuranceOrder.IMEI)</td>
                </tr>
            </table>
                //已处理和取消报案的只需要查看
                if (ViewBag.ParentStatusCode == (byte)InsuranceWarrantyStatus.Processed || Model.Status == (byte)InsuranceWarrantyStatus.Canceled)
                {

                    <h4>案件处理信息</h4>
                    <table class="table table-striped table-bordered table-hover">
                        <thead>
                            <tr>
                                <th width="100px">序号</th>
                                <th>损失名称</th>
                                <th>损失数量</th>
                                <th>维修商结算价</th>
                                <th>保险结算价</th>
                            </tr>
                        </thead>
                        <tbody>
                            @* ReSharper disable once InconsistentNaming *@
                            @for (int i = 0; i < Model.InsuranceWarrantyRecordItem.Count; i++)
                            {
                                var InsuranceWarrantyRecordItem = Model.InsuranceWarrantyRecordItem.ToList();
                                <tr class="text-center" id="trInsuranceWarrantyRecordItem_@(i)">
                                    <td>
                                        @(i + 1)
                                    </td>
                                    <td>
                                        @Html.HiddenFor(m => InsuranceWarrantyRecordItem[i].ID)
                                        @Html.HiddenFor(m => InsuranceWarrantyRecordItem[i].InsuranceWarrantyRecordId)
                                        @Html.DisplayFor(m => InsuranceWarrantyRecordItem[i].LostName)
                                    </td>
                                    <td>
                                        @Html.DisplayFor(m => InsuranceWarrantyRecordItem[i].LostCount)
                                    </td>
                                    <td>
                                        @Html.DisplayFor(m => InsuranceWarrantyRecordItem[i].LostPriceForUser)
                                    </td>
                                    <td>
                                        @Html.DisplayFor(m => InsuranceWarrantyRecordItem[i].LostNuclearPrice)
                                    </td>
                                </tr>
                            }
                            <tr>
                                <td>处理结果：</td>
                                <td colspan="4">@Model.RepairRemark</td>
                            </tr>
                        </tbody>
                    </table>
                    if (Model.InsuranceWarrantyRecordFree.Any())
                    {
                        <h4>其他费用</h4>
                        <table class="table table-striped table-bordered table-hover">
                            <thead>
                                <tr>
                                    <th>序号</th>
                                    <th>费用类型</th>
                                    <th>总额</th>
                                </tr>
                            </thead>
                            <tbody>
                                @for (int j = 0; j < Model.InsuranceWarrantyRecordFree.Count; j++)
                                {
                                    var InsuranceWarrantyRecordFree = Model.InsuranceWarrantyRecordFree.ToList();
                                    <tr class="text-center" id="trInsuranceWarrantyRecordFree_@(j)">
                                        <td>
                                            @(j + 1)
                                        </td>
                                        <td>
                                            @Html.HiddenFor(m => InsuranceWarrantyRecordFree[j].ID)
                                            @Html.HiddenFor(m => InsuranceWarrantyRecordFree[j].InsuranceWarrantyRecordId)
                                            @Html.DropDownListFor(m => InsuranceWarrantyRecordFree[j].FeeType, ConvertToSelector.Instance.EnumTypeConvertToSelectList(typeof(InsuranceRecordFreeTypeEnums), InsuranceWarrantyRecordFree[j].FeeType), new { disabled = "disabled" })
                                        </td>
                                        <td>
                                            @Html.DisplayFor(m => InsuranceWarrantyRecordFree[j].Amount)
                                        </td>
                                    </tr>
                                }
                            </tbody>
                        </table>
                    }

                }
                else
                {
                    <h4>案件处理信息</h4>
                    <table class="table table-striped table-bordered table-hover" id="tbInsuranceWarrantyRecordItem">
                        <thead>
                            <tr>
                                <th>序号</th>
                                <th>损失名称</th>
                                <th>
                                    损失数量
                                </th>
                                <th>维修商结算价</th>
                                <th>保险结算价</th>
                                <th class="width-30">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            @* ReSharper disable once InconsistentNaming *@
                            @for (int i = 0; i < Model.InsuranceWarrantyRecordItem.Count; i++)
                            {
                                var InsuranceWarrantyRecordItem = Model.InsuranceWarrantyRecordItem.ToList();
                                <tr class="text-center" id="trInsuranceWarrantyRecordItem_@(i)">
                                    <td>
                                        @(i + 1)
                                    </td>
                                    <td>
                                        @Html.HiddenFor(m => InsuranceWarrantyRecordItem[i].ID)
                                        @Html.HiddenFor(m => InsuranceWarrantyRecordItem[i].InsuranceWarrantyRecordId)
                                        @Html.TextBoxFor(m => InsuranceWarrantyRecordItem[i].LostName, new { validate = "{messages:{required:'损失名称必填！'}}" })
                                    </td>
                                    <td>
                                        @Html.TextBoxFor(m => InsuranceWarrantyRecordItem[i].LostCount, new { validate = "{number:true,min:0,messages:{required:'请填写数量'}}", onkeyup = "onlyInputInt(this);calculateAmount('InsuranceWarrantyRecordItem_" + i + "__')" })
                                    </td>
                                    <td>
                                        @Html.TextBoxFor(m => InsuranceWarrantyRecordItem[i].LostPriceForUser, new { validate = "{number:true,messages:{required:'维修商结算价必填'}}", onkeyup = "onlyInputDecimal(this,2)", MaxLength = "11" })
                                    </td>
                                    <td>
                                        @Html.TextBoxFor(m => InsuranceWarrantyRecordItem[i].LostNuclearPrice, new { validate = "{number:true,messages:{required:'保险结算价必填'}}", onkeyup = "onlyInputDecimal(this,2)", MaxLength = "11" })
                                    </td>
                                    <td>
                                        <a class='Edit-R ' href="javascript:void(0)" title='delete' onclick="removeInsuranceWarrantyRecordItem('trInsuranceWarrantyRecordItem_@i')"><i class='icon-remove'></i></a>
                                    </td>
                                </tr>
                            }
                        </tbody>
                        <tfoot>
                            <tr>
                                <td colspan="6">
                                    <input id="btnAddNewRow" class="btn btn-primary Edit-R" type="button" value="新增行">
                                </td>
                            </tr>
                        </tfoot>
                    </table>
                    <h4>其他费用</h4>
                    <table class="table table-striped table-bordered table-hover" id="tbInsuranceWarrantyRecordFree">
                        <thead>
                            <tr>
                                <th width="48">序号</th>
                                <th>费用类型</th>
                                <th>总额</th>
                                <th class="width-30">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            @for (int j = 0; j < Model.InsuranceWarrantyRecordFree.Count; j++)
                            {
                                var InsuranceWarrantyRecordFree = Model.InsuranceWarrantyRecordFree.ToList();
                                <tr class="text-center" id="trInsuranceWarrantyRecordFree_@(j)">
                                    <td>
                                        @(j + 1)
                                    </td>
                                    <td>
                                        @Html.HiddenFor(m => InsuranceWarrantyRecordFree[j].ID)
                                        @Html.HiddenFor(m => InsuranceWarrantyRecordFree[j].InsuranceWarrantyRecordId)
                                        @Html.DropDownListFor(m => InsuranceWarrantyRecordFree[j].FeeType, ConvertToSelector.Instance.EnumTypeConvertToSelectList(typeof(InsuranceRecordFreeTypeEnums), InsuranceWarrantyRecordFree[j].FeeType))
                                    </td>
                                    <td>
                                        @Html.TextBoxFor(m => InsuranceWarrantyRecordFree[j].Amount, new { validate = "{number:true}", onkeyup = "onlyInputDecimal(this,2)", MaxLength = "11" })
                                    </td>
                                    <td>
                                        <a class='Edit-R ' href="javascript:void(0)" title='delete' onclick="removetbInsuranceWarrantyRecordFree('trInsuranceWarrantyRecordFree_@j')"><i class='icon-remove'></i></a>
                                    </td>
                                </tr>
                            }
                        </tbody>
                        <tfoot>
                            <tr>
                                <td colspan="4">
                                    <input id="btnAddinsuranceWarrantyRecordFreeNewRow" class="btn btn-primary Edit-R" type="button" value="新增行">
                                </td>
                            </tr>
                        </tfoot>
                    </table>
                    <h4>
                        任务处理：
                        <select id="ParentId" name="ParentId" validate="{required:true,messages:{required:'请选择处理结果'}}"></select>
                        <select id="ChildrenId" name="ChildrenId" style="display:none;" validate="{required:true,messages:{required:'请选择处理结果'}}"></select>
                        <input type="hidden" id="oldStatus" value="@(Model.Status)" /> <!--当前状态，在页面中不会改变，不提交-->
                        <input type="hidden" id="Status" name="Status" value="@(Model.Status)" /> <!--当前状态，选择状态后会改变，会提交-->
                        <input type="hidden" id="ParentStatusId" value="@(ViewBag.ParentStatusId)" />
                        <div id="StatusReasonDiv" style="display:none; margin-top:10px;">
                            状态备注：
                            <select id="StatusReason" name="StatusReasonId" style="min-width:121px" validate="{required:true,messages:{required:'请选择状态备注'}}"></select>
                        </div>

                        @*@Html.DropDownListFor(c => c.Status, ConvertToSelector.Instance.EnumTypeConvertToSelectList(typeof(InsuranceWarrantyStatus)), new { validate = "{required:true,messages:{required:'请选择处理结果'}}" })
                              <script>
                                  $(function () {
                                      $("#Status option[value='@((byte)InsuranceWarrantyStatus.Created)']").remove();
                                      $("#Status option[value='@((byte)InsuranceWarrantyStatus.RetrurnVisited)']").remove();
                                  });
                            </script>*@
                    </h4>
                    <div>
                        @Html.TextAreaFor(m => m.RepairRemark, new { @class = "w-p98", placeholder = "请填写维修处理结果方案详情" })
                    </div>
                    <div class="form-actions text-center">
                        <input class="btn btn-primary Edit-R" type="submit" value="提交">
                    </div>
                }
        }

        @if (Model.Status == (byte)InsuranceWarrantyStatus.Close)
        {
            if (Request["IsToVisit"] == "true")
            {
                <h4>回访信息</h4>
                using (Html.BeginForm("SaveReturnVisit", "InsuranceWarrantyRecord", FormMethod.Post, new { id = "mvcForm", name = "mvcForm", enctype = "multipart/form-data" }))
                {
                    @Html.AntiForgeryToken()
                    @Html.HiddenFor(m => m.ID)
                    @Html.HiddenFor(m => m.InsuranceOrderId)
                    <div>
                        <div class="float-left">用户评分：</div>
                        <div id="WarrantyServiceScore" class="star-rate w120">
                        </div>
                    </div>
                    <div>
                        @Html.TextAreaFor(m => m.ReturnVisitResult, new { validate = "{required:true,messages:{required:'回访备注必填'}}", @class = "w-p98", placeholder = "请填写回访备注" })
                    </div>
                    <div class="form-actions text-center">
                        <input id="btnSave" class="btn btn-primary Edit-R" type="submit" value="提交">
                    </div>
                }
            }
        }
        else if (Model.Status == (byte)InsuranceWarrantyStatus.RetrurnVisited)
        {
            <h4>回访信息</h4>
            <div>
                回访时间：@Model.ReturnVisitTime
            </div>
            <div class="w200">
                <div class="float-left">用户评分：</div>
                @Html.Hidden("WarrantyServiceScore", Model.WarrantyServiceScore)
                <div id="star" class="w200"></div>
            </div>
            <div>
                回访备注：@Model.ReturnVisitResult
            </div>
        }
    </div>
    <div class="tab-pane padding-10 fade in" id="processLog">
        @RenderPage("/Views/InsuranceWarrantyRecord/ProcessLogsIndex.cshtml", new { InsuranceWarrantyRecordId = Model.ID })
    </div>
    <div class="tab-pane fade in" id="OpreateLogs">
        @RenderPage("/Views/OpreateLogs/Index.cshtml", new { LogTableName = "InsuranceWarrantyRecord", LogTablePKID = id })
    </div>
</div>



@section scripts{
    @Scripts.Render("~/bundles/datatable")
    @Styles.Render("~/Content/datatable")
    @Scripts.Render("~/bundles/chosen")
    <script type="text/javascript">
        $(function () {
            $("#WarrantyServiceScore").raty({
                score: $("#Grade").val(),
                scoreName: "WarrantyServiceScore"
            });

            $("#star").raty({
                readOnly: true,
                score: $("#WarrantyServiceScore").val()
            });

            $('#tbInsuranceWarrantyRecordItem').dataTable({
                "bServerSide": false,
                "bProcessing": false,
                "allowHeaderDoubleClick": true,
                "bSort": false,
                "sDom": "R", //可拖拽
                "oColReorder": {
                    "bAddFixed": false
                }
            });
            $('#tbInsuranceWarrantyRecordFree').dataTable({
                "bServerSide": false,
                "bProcessing": false,
                "allowHeaderDoubleClick": true,
                "bSort": false,
                "sDom": "R", //可拖拽
                "oColReorder": {
                    "bAddFixed": false
                }
            });

            //增加行
            $("#btnAddNewRow").click(function () {
                var html = $(document.getElementById("tbInsuranceWarrantyRecordItem").rows[1]).html();
                var lastTrId = $("#tbInsuranceWarrantyRecordItem tbody tr:last-child").attr("id");
                var newId = parseInt(lastTrId.substring(lastTrId.indexOf('_') + 1));
                var regExpOrderItem = new RegExp("0", "g"); //第一行序号都是0
                html = html.replace(regExpOrderItem, newId + 1);

                html = "<tr id='trInsuranceWarrantyRecordItem_" + (newId + 1) + "'>" + html + "</tr>";
                $("#tbInsuranceWarrantyRecordItem tbody").append(html);
                $("#tbInsuranceWarrantyRecordItem tbody tr:last-child input").val("");
                $("#tbInsuranceWarrantyRecordItem tbody tr:last-child td:first").html(newId + 2);
            });


            //任务处理状态默认选中
            var currentStatus = $("#Status").val();
            var parentStatusId = $("#ParentStatusId").val();
            statusChange("0", "", "ParentId", currentStatus, parentStatusId);
            // (parentId, parentCode, elementId, status, statusId)

            if (parentStatusId > 0)
                statusChange(parentStatusId, "", "ChildrenId", currentStatus, "");

            //工单状态选择
            $("#ParentId").change(function () {
                $("#Status").val("");
                var parentId = $(this).val();
                if (parentId) {
                    //加载二级状态
                    statusChange(parentId, $(this).find("option:selected").attr("StatusCode"), "ChildrenId");
                    //加载状态备注
                    GetStatusReason(parentId);
                }
                else {
                    $("#ChildrenId").html("").hide();
                }
            });
            $("#ChildrenId").change(function () {
                var _this = $(this);
                var newStatus = _this.find("option:selected").attr("StatusCode");
                $("#Status").val(newStatus);
                //debugger
                //console.log(_this.val())
                //console.log($("#oldStatus").val())
                //console.log(newStatus)
                //状态又被改回初始状态了
                if (newStatus == $("#oldStatus").val()) {
                    $("#StatusReasonDiv").hide();
                    $("#StatusReason").html("");
                }
                else
                    //加载状态备注
                    GetStatusReason(_this.val());
            });


        });
        //删除行
        function removeInsuranceWarrantyRecordItem(trInsuranceWarrantyRecordItemId) {
            if (($("#tbInsuranceWarrantyRecordItem tbody tr").length == 1)) {
                layer.alert("最后一行不能删除，至少保留一行！");
                return;
            }
            $("#" + trInsuranceWarrantyRecordItemId).remove();
            var i = 0;
            $("#tbInsuranceWarrantyRecordItem tbody tr").each(function () {
                $(this).find("td:first").html(i + 1);
                $(this).find("td:last").html("<a class='Edit-R ' href=\"javascript:void(0)\" title='delete' onclick=\"removeInsuranceWarrantyRecordItem('trInsuranceWarrantyRecordItem_" + i + "')\"><i class='icon-remove'></i></a>");
                $(this).attr("id", "trInsuranceWarrantyRecordItem_" + i);
                $(this).find("input").each(function () {
                    var regExpID = new RegExp("_\\d\+__", "g"); //替换ID
                    var regExpName = new RegExp("\\[\\d\+\\]", "g"); //替换Name

                    var id = $(this).attr("id");
                    var name = $(this).attr("name");

                    $(this).attr("id", id.replace(regExpID, "_" + i + "__"));
                    $(this).attr("name", name.replace(regExpName, "[" + i + "]"));

                    var clickEvent = $(this).attr("onclick");
                    if (clickEvent && clickEvent != "")
                        $(this).attr("onclick", clickEvent.replace(regExpID, "_" + i + "__"));

                    var onkeyupEvent = $(this).attr("onkeyup");
                    if (onkeyupEvent && onkeyupEvent != "")
                        $(this).attr("onkeyup", onkeyupEvent.replace(regExpID, "_" + i + "__"));
                });
                i++;
            });
        }
        //增加行
        $("#btnAddinsuranceWarrantyRecordFreeNewRow").click(function () {
            var html = $(document.getElementById("tbInsuranceWarrantyRecordFree").rows[1]).html();
            var lastTrId = $("#tbInsuranceWarrantyRecordFree tbody tr:last-child").attr("id");
            var newId = parseInt(lastTrId.substring(lastTrId.indexOf('_') + 1));
            var regExpOrderItem = new RegExp("0", "g"); //第一行序号都是0
            html = html.replace(regExpOrderItem, newId + 1);

            html = "<tr id='trInsuranceWarrantyRecordFree_" + (newId + 1) + "'>" + html + "</tr>";
            $("#tbInsuranceWarrantyRecordFree tbody").append(html);
            $("#tbInsuranceWarrantyRecordFree tbody tr:last-child select").val("");
            $("#tbInsuranceWarrantyRecordFree tbody tr:last-child input").val("");
            $("#tbInsuranceWarrantyRecordFree tbody tr:last-child td:first").html(newId + 2);
        });
        //删除行
        function removetbInsuranceWarrantyRecordFree(trInsuranceWarrantyRecordFreeId) {
            if (($("#tbInsuranceWarrantyRecordFree tbody tr").length == 1)) {
                layer.alert("最后一行不能删除，至少保留一行！");
                return;
            }
            $("#" + trInsuranceWarrantyRecordFreeId).remove();
            var i = 0;
            $("#tbInsuranceWarrantyRecordFree tbody tr").each(function () {
                $(this).find("td:first").html(i + 1);
                $(this).find("td:last").html("<a class='Edit-R ' href=\"javascript:void(0)\" title='delete' onclick=\"removetbInsuranceWarrantyRecordFree('trInsuranceWarrantyRecordFree_" + i + "')\"><i class='icon-remove'></i></a>");
                $(this).attr("id", "trInsuranceWarrantyRecordFree_" + i);
                $(this).find("input").each(function () {
                    var regExpID = new RegExp("_\\d\+__", "g"); //替换ID
                    var regExpName = new RegExp("\\[\\d\+\\]", "g"); //替换Name

                    var id = $(this).attr("id");
                    var name = $(this).attr("name");

                    $(this).attr("id", id.replace(regExpID, "_" + i + "__"));
                    $(this).attr("name", name.replace(regExpName, "[" + i + "]"));

                    var clickEvent = $(this).attr("onclick");
                    if (clickEvent && clickEvent != "")
                        $(this).attr("onclick", clickEvent.replace(regExpID, "_" + i + "__"));

                    var onkeyupEvent = $(this).attr("onkeyup");
                    if (onkeyupEvent && onkeyupEvent != "")
                        $(this).attr("onkeyup", onkeyupEvent.replace(regExpID, "_" + i + "__"));
                });
                i++;
            });
        }
        function showInsuranceOrderInfoLayer() {
            layer.open({
                type: 2,
                title: '保单信息',
                shadeClose: true,
                shade: 0.8,
                area: ['80%', '600px'],
                content: '/InsuranceWarrantyRecord/InsuranceOrderInfo?insuranceOrderId=' + $("#InsuranceOrderId").val() //iframe的url
            });
        }

        function showWarrantyRecordEditLayer() {
            layer.open({
                type: 2,
                title: '补充案件信息',
                shadeClose: true,
                shade: 0.8,
                area: ['880px', '650px'],
                content: '/InsuranceWarrantyRecord/Edit?id=' + $("#ID").val() //iframe的url
            });
        }

        function showIWRDataCollectLayer() {
            layer.open({
                type: 2,
                title: '资料收集',
                shadeClose: true,
                shade: 0.8,
                area: ['820px', '75%'],
                content: '/InsuranceWarrantyRecord/IWRDataCollect?insuranceWarrantyRecordId=' + $("#ID").val() //iframe的url
            });
        }

        function showIWRPickUpInfoLayer() {
            layer.open({
                type: 2,
                title: '取件信息',
                shadeClose: true,
                shade: 0.8,
                area: ['820px', '520px'],
                content: '/InsuranceWarrantyRecord/IWRPickUpInfo/' + $("#ID").val() //iframe的url
            });
        }

        function showSendBackInfoLayer() {
            layer.open({
                type: 2,
                title: '寄件信息',
                shadeClose: true,
                shade: 0.8,
                area: ['820px', '520px'],
                content: '/InsuranceWarrantyRecord/SendBackInfo/' + $("#ID").val() //iframe的url
            });
        }

        //任务状态选择
        function statusChange(parentId, parentCode, elementId, status, statusId) {
            //$("#Status").val("");
            $.ajax({
                url: "/Common/GetChildrenStatus?parentId=" + parentId,
                success: function (data) {
                    if (data && data.length > 0) {
                        var html = '<option value="">请选择</option>';
                        for (var i = 0; i < data.length; i++) {
                            if ((status && status == data[i].StatusCode) ||
                                (statusId && statusId == data[i].ID)
                                )
                                html += "<option value='" + data[i].ID + "' StatusCode=" + data[i].StatusCode + " selected='selected'>" + data[i].StatusName + "</option>";
                            else
                                html += "<option value='" + data[i].ID + "' StatusCode=" + data[i].StatusCode + ">" + data[i].StatusName + "</option>";

                        }
                        $("#" + elementId).show().html(html);
                    } else {
                        $("#" + elementId).hide().html("");
                        $("#Status").val(parentCode);
                    }
                }
            });
        }


        //加载状态备注
        function GetStatusReason(statusId) {
            $.ajax({
                url: "/Common/GetStatusReason?statusId=" + statusId,
                success: function (data) {
                    if (data && data.length > 0) {
                        var html = '<option value="">请选择</option>';
                        for (var i = 0; i < data.length; i++) {
                            html += "<option value='" + data[i].ID + "'>" + data[i].ReasonDescribe + "</option>";
                        }
                        $("#StatusReasonDiv").show();
                        $("#StatusReason").html(html);
                    } else {
                        $("#StatusReasonDiv").hide();
                        $("#StatusReason").html("");
                    }
                }
            });
        }
    </script>
}
